package com.gears_software.sxdc.dccx.ui.view;

import android.content.Context;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.gears_software.sxdc.dccx.R;
import com.gears_software.sxdc.dccx.data.model.FeeModel;
import com.orhanobut.logger.Logger;

import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

import java.math.BigDecimal;

/**
 * Created by SunMuran on 2017/9/20.
 * 收费明细的listView的View
 */
@EViewGroup(R.layout.item_charge_schedule_view)
public class ChargeScheduleListItemView extends LinearLayout {

    @ViewById
    TextView tv_feiyong;
    @ViewById
    TextView tv_feiyong_count;
    @ViewById
    TextView tv_danwei;
    @ViewById
    TextView tv_feiyong_money;

    public ChargeScheduleListItemView(Context context) {
        super(context);
    }

    public void bind(FeeModel model) {
//        if(model.getFeetype().equals("夜间费")||model.getFeetype().equals("高峰费")){
//            tv_feiyong.setText(model.getFeetype());
//            tv_feiyong_money.setText(model.getFeeamount()+"元");
//            tv_feiyong_count.setVisibility(GONE);
//            tv_danwei.setVisibility(GONE);
//        }else if(model.getFeetype().equals("时长费")||model.getFeetype().equals("里程费")){
//            tv_feiyong.setText(model.getFeetype());
//            tv_feiyong_count.setText(model.getFeeno()+"");
//            tv_danwei.setText(model.getFeeunit());
//            tv_feiyong_money.setText(model.getFeeamount()+"元");
//        }
        tv_feiyong.setText(model.getFeetype());
        Logger.d(model.getFeeno().toString());
        if (!model.getFeeno().equals(BigDecimal.ZERO)) {
            tv_feiyong_count.setVisibility(VISIBLE);
            tv_danwei.setVisibility(VISIBLE);
            tv_feiyong_count.setText(model.getFeeno().toString());
            tv_danwei.setText(model.getFeeunit());
        } else {
            tv_feiyong_count.setVisibility(GONE);
            tv_danwei.setVisibility(GONE);
        }
        if (model.getFeeamount() != null && !model.getFeeamount().equals("")) {
            tv_feiyong_money.setText(model.getFeeamount().toString() + "元");
        } else {
            tv_feiyong_money.setVisibility(GONE);
        }
    }
}
